package com.mak001.lite.multiSkill.GUI.Tabs;

import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Rectangle;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

import com.rsbuddy.script.wrappers.Area;
import com.rsbuddy.script.wrappers.Tile;

public class RCTab extends JPanel {
	private static final long serialVersionUID = 1L;

	private JTextField textField9;
	private JComboBox runeDropDown;
	String[] runes = { "air", "mind", "water", "earth", "fire", "body" };

	public RCTab() {
		textField9 = new JTextField();
		runeDropDown = new JComboBox();
		this.setLayout(null);

		// ---- textField9 ----
		textField9.setText("Type of Rune to Craft");
		textField9.setEditable(false);
		textField9.setHorizontalAlignment(SwingConstants.CENTER);
		this.add(textField9);
		textField9
				.setBounds(145, 25, 125, textField9.getPreferredSize().height);

		// ---- runeDropDown ----
		runeDropDown.setModel(new DefaultComboBoxModel(runes));
		this.add(runeDropDown);
		runeDropDown.setBounds(145, 50, 125,
				runeDropDown.getPreferredSize().height);

		{ // compute preferred size
			Dimension preferredSize = new Dimension();
			for (int i = 0; i < this.getComponentCount(); i++) {
				Rectangle bounds = this.getComponent(i).getBounds();
				preferredSize.width = Math.max(bounds.x + bounds.width,
						preferredSize.width);
				preferredSize.height = Math.max(bounds.y + bounds.height,
						preferredSize.height);
			}
			Insets insets = this.getInsets();
			preferredSize.width += insets.right;
			preferredSize.height += insets.bottom;
			this.setMinimumSize(preferredSize);
			this.setPreferredSize(preferredSize);
		}
	}

	public Area getRune() {
		String s = runeDropDown.getSelectedItem().toString();
		if (s.contains("air")) {
			return new Area(new Tile(3124, 3402), new Tile(3131, 3409));
		} else if (s.contains("earth")) {
			return new Area(new Tile(3303, 3471), new Tile(3309, 3477));
		} else if (s.contains("body")) {
			return new Area(new Tile(3050, 3442), new Tile(3056, 3448));
		} else if (s.contains("mind")) {
			return new Area(new Tile(2979, 3511), new Tile(2985, 3517));
		} else if (s.contains("water")) {
			return new Area(new Tile(3182, 3161), new Tile(3188, 3168));
		} else {// fire
			return new Area(new Tile(3309, 3252), new Tile(3317, 3259));
		}
	}

	public int getTally() {
		String s = runeDropDown.getSelectedItem().toString();
		if (s.contains("air")) {
			return 1438;
		} else if (s.contains("mind")) {
			return 1448;
		} else if (s.contains("water")) {
			return 1444;
		} else if (s.contains("earth")) {
			return 1440;
		} else if (s.contains("fire")) {
			return 1442;
		} else {// body
			return 1446;
		}
	}

}
